package chat

import (
	"encoding/json"
)

func SendMessageContentToUuid(uuid string, msg Message) {
	if cli, ok := clients[uuid]; ok {
		sendMessage(cli, msg)
	}
}

func SendMessageToUuid(uuid string, msg string) {
	//log.Println("clients=", clients)
	if cli, ok := clients[uuid]; ok {
		message := Message{}
		json.Unmarshal([]byte(msg), &message)
		//log.Println("未读消息队列：", message)
		sendMessage(cli, message)
	}
}

func sendMessage(c *Client, msg Message) error {
	c.hub.broadcast <- msg
	return nil
}
